package com.divine.wn.car.action;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.divine.wn.car.form.WriteReceiptForm;
import com.divine.wn.car.vo.BackUserVO;
import com.divine.wn.car.vo.LogVO;
import com.divine.wn.car.vo.UserVO;

public class WriteReceiptAction extends BaseAction {

	// 这个方法主要是为了获取和计算页面上的套餐值,只有业务员才会使用
	public ActionForward getTCData(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		
		//如果用户没有登录，或者用户不是业务员，则退出系统让他重新登录。		
		if (backUser == null||!backUser.getRoleid().equals("1")) {
			response.sendRedirect("login.do?callMethod=forwardLogin");
			return null;
		}
		
		
		UserVO userVO = wForm.getUserVO();
		request.setAttribute("areaList",backUserService.getBackUserArea());
		request.setAttribute("cllxList", baseDataService.getCllx());
		
		//如果该用户没有配置地区，或者该地区没有配置套餐
		if(userVO.getAreaid()==null||userVO.getAreaid().equals("")){
			request.setAttribute("tcList", new ArrayList());
			return mapping.findForward("input");
		}
		
		request.setAttribute("tcList", baseDataService.getTC(userVO.getAreaid()));
		
		
		// 车价是计算其他费用的基础，如果没有填写，则自动默认为0
		if ("".equals(userVO.getJg().trim())||"0".equals(userVO.getJg().trim())) {
			userVO.setJg("0");
			return mapping.findForward("input");
		}

		// 根据套餐ID获取到套餐的所有比率值
		String tcID = userVO.getTcid();
		
		List<HashMap<String,Float>> tcList= baseDataService.getTCData(tcID);
		
		
		//格式化价格
		userVO.setJg(changeData("100",new BigDecimal(userVO.getJg()).setScale(2,BigDecimal.ROUND_HALF_UP).toString()));

		//格式化首付，首付是按照价格*车辆类型的比率计算的
		userVO.setShoufu(changeData(userVO.getJg(), userVO.getCllx_rate()));

		//贷款额  贷款额=车价-首付
		BigDecimal dke=new BigDecimal(userVO.getJg()).subtract(new BigDecimal(userVO.getShoufu())).setScale(2, BigDecimal.ROUND_HALF_UP);
		if(dke.toString().length()>6){
			userVO.setDke(dke.toString().substring(0,dke.toString().indexOf(".")-3)+"000.00");
		}else{
			userVO.setDke(dke.toString());
		}
		userVO.setShoufu(new BigDecimal(userVO.getJg()).subtract(new BigDecimal(userVO.getDke())).toString());
		
		
		//根据套餐获取监管费用，如果后台配置的监管费为比率，则按照比率计算，否则则直接获取后台价格。
		if(new Float(tcList.get(5).get("cost_fl").toString())==1){
			userVO.setJgf(changeData("100",tcList.get(5).get("rate")+""));
		}else{
			userVO.setJgf(changeData(userVO.getDke(),tcList.get(5).get("rate")+""));
		}
		
			
		//获取抵押公证费
		if(new Float(tcList.get(2).get("cost_fl").toString())==1){
			userVO.setDygzf(changeData("100",tcList.get(2).get("rate")+""));
		}else{
			userVO.setDygzf(changeData(userVO.getDke(),tcList.get(2).get("rate")+""));
		}
		
		//手续费
		if(new Float(tcList.get(1).get("cost_fl").toString())==1){
			userVO.setSxf(changeData("100",tcList.get(1).get("rate")+""));
		}else{
			userVO.setSxf(changeData(userVO.getDke(),tcList.get(1).get("rate")+""));
		}
		
		//担保费
		if(new Float(tcList.get(3).get("cost_fl").toString())==1){
			userVO.setDbf(tcList.get(3).get("rate")+"");
		}else{
			userVO.setDbf(changeData(userVO.getDke(),tcList.get(3).get("rate")+""));
		}
		
		//车队服务费
		userVO.setCdfwf1(changeData("100",tcList.get(4).get("rate")+""));
		userVO.setCdfwf2(changeData("100",tcList.get(8).get("rate")+""));
		userVO.setCdfwf3(changeData("100",tcList.get(9).get("rate")+""));
		
		//GPS费
		userVO.setGpsf1(changeData("100",tcList.get(11).get("rate")+""));
		userVO.setGpsf2(changeData("100",tcList.get(12).get("rate")+""));
		userVO.setGpsf3(changeData("100",tcList.get(13).get("rate")+""));
		
		//如果没有选择车队服务费，则默认为第一个。如果车队服务费整个发生变化，也选择第一个
		if(userVO.getCdfwf()==null){
			userVO.setCdfwf(userVO.getCdfwf1());
		}else if(!userVO.getCdfwf().equals(userVO.getCdfwf1())&&!userVO.getCdfwf().equals(userVO.getCdfwf2())&&!userVO.getCdfwf().equals(userVO.getCdfwf3())){
			userVO.setCdfwf(userVO.getCdfwf1());
		}
		
		//如果没有选择GPS费，则默认为第一个。如果GPS费整个发生变化，也选择第一个
		if(userVO.getGpsf()==null){
			userVO.setGpsf(userVO.getGpsf1());
		}else if(!userVO.getGpsf().equals(userVO.getGpsf1())&&!userVO.getGpsf().equals(userVO.getGpsf2())&&!userVO.getGpsf().equals(userVO.getGpsf3())){
			userVO.setGpsf(userVO.getGpsf1());
		}
		
		
		//保证金
		if(new Float(tcList.get(6).get("cost_fl").toString())==1){
			userVO.setBzj(tcList.get(6).get("rate")+"");
		}else{
			userVO.setBzj(changeData(userVO.getDke(),tcList.get(6).get("rate")+""));
		}
		
		//预收
		if(new Float(tcList.get(7).get("cost_fl").toString())==1){
			userVO.setYs(tcList.get(7).get("rate")+"");
		}else{
		
			String ys=changeData(userVO.getJg(),	tcList.get(7).get("rate")+"").toString();
			
			if(ys.length()<=4||ys.substring(ys.indexOf(".")-1, ys.length()).equals("0.00")){
				userVO.setYs(ys);
			}else if(ys.length()>4){
				userVO.setYs(new Integer(ys.substring(0,ys.indexOf(".")-1))+1+"0.00");
			}
		}
		
		//应缴部分
		userVO.setYjk(new BigDecimal(userVO.getKhscf())
		.add(new BigDecimal(userVO.getSxf()))
		.add(new BigDecimal(userVO.getDygzf()))
		.add(new BigDecimal(userVO.getDbf()))
		.add(new BigDecimal(userVO.getCdfwf()))
		.add(new BigDecimal(userVO.getGpsf()))
		.add(new BigDecimal(userVO.getJgf()))
		.add(new BigDecimal(userVO.getBzj()))
		.add(new BigDecimal(userVO.getYs()))
		.add(new BigDecimal(userVO.getShoufu()))
		.setScale(2, BigDecimal.ROUND_HALF_UP).toString());


		return mapping.findForward("input");
	}

	// 这个方法主要是为了获取和计算页面上的套餐值,只有业务员才会使用
	public ActionForward getKhscf(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		
		//如果用户没有登录，或者用户不是业务员，则退出系统让他重新登录。		
		if (backUser == null||!backUser.getRoleid().equals("1")) {
			response.sendRedirect("login.do?callMethod=forwardLogin");
			return null;
		}
		
		
		UserVO userVO = wForm.getUserVO();
		List<HashMap<String,Float>> khList= baseDataService.getKhscf(userVO.getAreaid());
		
		
		//客户审查费
			userVO.setKhscf(changeData("100",khList.get(0).get("khscf")+""));


		return getTCData(mapping,form,request,response);
	}

	
	
	
	//业务员提交审批
	public ActionForward submitUser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		WriteReceiptForm wForm = (WriteReceiptForm) form;
		UserVO userVO = wForm.getUserVO();

		
		//如果用户没有登录，或者用户不是业务员，则退出系统让他重新登录。		
		if (backUser == null||!backUser.getRoleid().equals("1")) {
			response.sendRedirect("login.do?callMethod=forwardLogin");
			return null;
		}
		
		//设置成功提交到下一个处理人信息
		String nextRole=baseDataService.getNextRole(userVO.getWorkflowid());		
		request.setAttribute("submitUser", "成功提交到"+nextRole+"审批！");

		//如果是退回，或者是刷新重新提交，则直接转向成功页面，避免再次提交。
		if(!this.isTokenValid(request)){
			return mapping.findForward("success");
		}
		if(StringUtils.isBlank(userVO.getId())){
			userVO.setMark(changeData("100", userVO.getMark()));
			String user_tableid = userService.insertUser(userVO).toString();
			HashMap<String,Object> map=new HashMap<String, Object>();
			map.put("workflowid", userVO.getWorkflowid());			
			map.put("userid", backUser.getUserID());
			map.put("usertableid", user_tableid);
			workflowService.insertWorkFlow(map);

			// 记录日志
			LogVO logVO = new LogVO();
			logVO.setLog(backUser.getRole() + backUser.getUsername() + "提交客户资料");
			logVO.setUser_tableid(user_tableid);
			logVO.setBuserid(backUser.getUserID());
			logVO.setRole("1");
			logVO.setMark(request.getParameter("mark"));
			logService.insertLog(logVO);
		}else{
			userVO.setWorkflowid("2");
			userService.updateUser(userVO);
			String user_tableid=userVO.getId();
			
			// 记录日志
			LogVO logVO = new LogVO();
			logVO.setLog(backUser.getRole() + backUser.getUsername() + "提交客户资料");
			logVO.setUser_tableid(user_tableid);
			logVO.setBuserid(backUser.getUserID());
			logVO.setRole("1");
			logVO.setMark(request.getParameter("mark"));
			logService.insertLog(logVO);
			
		}
			
			
			
			this.resetToken(request);


		return mapping.findForward("success");
	}
	
	
	
	
	public ActionForward getUserInfo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;
	
		//如果用户session失效，马上退回让用户重新登录
		

		if (backUser == null) {
			return mapping.findForward("fail");
		}

		UserVO userVO = userService.getUser(new Integer(wForm.getTableID()));
		
		if(backUser.getRoleid().equals("9")||backUser.getRoleid().equals("7")){
			request.setAttribute("payList", userService.getPay(wForm.getUserVO().getId()+""));
		}else{
			request.setAttribute("payList", null);
		}

		wForm.setUserVO(userVO);
		
		
		//填写打印部分
		request.setAttribute("xj1",new BigDecimal(userVO.getBzj()).add(new BigDecimal(userVO.getJgf())).add(new BigDecimal(userVO.getDygzf())).add(new BigDecimal(userVO.getKhscf())).add(new BigDecimal(userVO.getGpsf())));
		request.setAttribute("xj2",new BigDecimal(userVO.getDbf()).add(new BigDecimal(userVO.getCdfwf())).add(new BigDecimal(userVO.getSxf())));
		request.setAttribute("rate",StringUtils.right(userVO.getCllx_rate(), userVO.getCllx_rate().length()-1-userVO.getCllx_rate().indexOf("_")));

		//查询日志列表
		request.setAttribute("logList",logService.getLogList(new Integer(wForm.getTableID())));

		return mapping.findForward("info");
	}
	
	
	//转到填单页面
	public ActionForward toUserPage(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		this.saveToken(request);
		
		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		List<HashMap<String,Object>>  areaList=backUserService.getBackUserArea();
		
		request.setAttribute("areaList",areaList);		
		request.setAttribute("cllxList", baseDataService.getCllx());
		List<HashMap<String,Object>>  tcList=new ArrayList<HashMap<String,Object>> ();;
		if(areaList.size()>0){
			tcList=baseDataService.getTC(areaList.get(0).get("areaID")+"");
		}		
		request.setAttribute("tcList", tcList);
		
		
WriteReceiptForm wForm = (WriteReceiptForm) form;


		
		
		UserVO userVO = wForm.getUserVO();
		List<HashMap<String,Float>> khList= baseDataService.getKhscf(areaList.get(0).get("areaID")+"");

		//客户审查费
		
			userVO.setKhscf(changeData("100",khList.get(0).get("khscf")+""));
	
		
		//将用户信息放入Hashmap中，以便后面使用
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("roleid", backUser.getRoleid());
		map.put("userid", backUser.getUserID());
		
	
		//查询用户处理过的业务单据数量
		request.setAttribute("historyCount", userService.getHistoryCount(map));
		map.put("returnData", "true");
		request.setAttribute("returnCount", userService.getHistoryCount(map));
		return mapping.findForward("input");
	}
	
	//转到修改单据页面
	public ActionForward fengcun(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		if(!this.isTokenValid(request)){
			return mapping.findForward("success");
		}
		
		
		//如果用户session失效，马上退回让用户重新登录
		if (backUser == null) {
			return mapping.findForward("fail");
		}

		HashMap<String,Object> map = new HashMap<String,Object>();
		String user_tableid=request.getParameter("userVO.id");	
		
		map.put("usertableid", user_tableid);
		map.put("workflowid","9999");
		
		userService.updateStatus(map);		
		
		// 记录日志
		LogVO logVO = new LogVO();
		logVO.setLog(backUser.getRole() + backUser.getUsername() + "已封存客户资料");
		logVO.setUser_tableid(user_tableid);
		logVO.setBuserid(backUser.getUserID());
		
		logVO.setMark(request.getParameter("mark"));
		
		logService.insertLog(logVO);
		request.setAttribute("approved", "单据已封存！");
		
		
		
		this.resetToken(request);

		return mapping.findForward("success");
	}
	
	
	//转到修改单据页面
	public ActionForward toEditUser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		//进入修改用户页面之前，需要设置token
		this.saveToken(request);
		WriteReceiptForm wForm = (WriteReceiptForm) form;
		
		//如果用户session失效，马上退回让用户重新登录
		if (backUser == null) {
			return mapping.findForward("fail");
		}

		UserVO userVO = userService.getUser(new Integer(wForm.getTableID()));
		
		

		wForm.setUserVO(userVO);
		if(backUser.getRoleid().equals("9")||backUser.getRoleid().equals("7")){
			request.setAttribute("payList", userService.getPay(wForm.getUserVO().getId()+""));
		}else{
			request.setAttribute("payList", null);
		}
		
		
		//如果是业务员修改，则需要查询，否则不需要查询
		if(backUser.getRoleid().equals("1")){
			request.setAttribute("cllxList", baseDataService.getCllx());
			request.setAttribute("tcList", baseDataService.getTC(userVO.getAreaid()));
			request.setAttribute("areaList", backUserService.getBackUserArea());
			
			List<HashMap<String,Float>> tcList= baseDataService.getTCData(userVO.getTcid());
			
			//车队服务费
			userVO.setCdfwf1(tcList.get(4).get("rate")+"");
			userVO.setCdfwf2(tcList.get(9).get("rate")+"");
			userVO.setCdfwf3(tcList.get(10).get("rate")+"");
		}
		HashMap<String,Object> map = new HashMap<String,Object>();
		
		

		// 获取被退回的数量
		map.put("roleid", backUser.getRoleid());
		map.put("userid", backUser.getUserID());
		
		
		
		//获取已处理的数据 
		request.setAttribute("historyCount", userService.getHistoryCount(map));
		//获取退回的单据数量
		map.put("returnData", "true");
		request.setAttribute("returnCount", userService.getHistoryCount(map));

		//查询日志列表
		request.setAttribute("logList",logService.getLogList(new Integer(wForm.getTableID())));

		return mapping.findForward("input");
	}
	
	
	//审核或者拒绝用户资料
	public ActionForward approveUser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		
		
		//获取通过或者拒绝的标识   1，2代表通过
		String approveStatus=request.getParameter("approveStatus");
		HashMap<String,Object> map = new HashMap<String,Object>();
		String user_tableid=request.getParameter("userVO.id");			
		map.put("usertableid", user_tableid);
		
		//如果已经审批过，则重新定向到待审批页面
		if(!(request.getParameter("userVO.workflowid").equals(userService.getStatus(map)+""))){
			return returnToList(mapping, form, request, response);
		}
		
		
		if("1".equals(approveStatus)||"2".equals(approveStatus)){//通过
			
			map.put("workflowid",new Integer(request.getParameter("userVO.workflowid")));
			
			
			if(backUser.getRoleid().equals("7")){
				WriteReceiptForm wForm = (WriteReceiptForm) form;
				if(wForm.getUserVO().getYytime().equals("点击选择日期")){
					wForm.getUserVO().setYytime("1900-1-1");
					
				}
				
				userService.updateXSZ(wForm.getUserVO());
				userService.updateBX(wForm.getUserVO());
				request.setAttribute("approved", "保险资料，营运证，驾驶证维护成功！");
				this.resetToken(request);

				return mapping.findForward("success");
			}
			
			map.put("userid", backUser.getUserID());			
			workflowService.updateWorkflow(map);
			
			// 记录日志
			LogVO logVO = new LogVO();
			logVO.setLog(backUser.getRole() + backUser.getUsername() + "审核通过客户资料");
			logVO.setUser_tableid(user_tableid);
			logVO.setBuserid(backUser.getUserID());
			
			logVO.setMark(request.getParameter("mark"));
			
			logService.insertLog(logVO);
			
			map.put("workflowid",new Integer(request.getParameter("userVO.workflowid"))+1);
			
			userService.updateStatus(map);

			
		
				//设置成功提交到下一个处理人信息
				String nextRole=baseDataService.getNextRole(request.getParameter("userVO.workflowid"));
				request.setAttribute("approved", "成功提交到"+nextRole+"审批！");
			
			
		}else if("0".equals(approveStatus)){//退回
			
			map.put("workflowid","1");			
			userService.updateStatus(map);
		
			map.put("usertableid", user_tableid);
			map.put("workflowid", request.getParameter("userVO.workflowid"));
			map.put("userid", backUser.getUserID());
			workflowService.updateWorkflow(map);
			
			// 记录日志
			LogVO logVO = new LogVO();
			logVO.setLog(backUser.getRole() + backUser.getUsername() + "退回客户资料");
			logVO.setUser_tableid(user_tableid);
			logVO.setBuserid(backUser.getUserID());
			logVO.setMark(request.getParameter("mark"));
			
			
			logService.insertLog(logVO);
			
			
			//转到处理成功页面需要查询待处理的数量
			int dataCount = userService.getdataCount(map);
			request.setAttribute("dataCount", dataCount);
			
			request.setAttribute("approved", "成功退回单据给业务员处理！");
			
		}
		
		
		else  if("-1".equals(approveStatus)){//作废			
			map.put("usertableid", user_tableid);
			map.put("workflowid", "999");
			
			userService.updateStatus(map);
			
			map.put("usertableid", user_tableid);
			map.put("workflowid", request.getParameter("userVO.workflowid"));
			map.put("userid", backUser.getUserID());
			
			workflowService.updateWorkflow(map);
			
			
			// 记录日志
			LogVO logVO = new LogVO();
			logVO.setLog(backUser.getRole() + backUser.getUsername() + "拒绝通过客户资料，单据已作废");
			logVO.setUser_tableid(user_tableid);
			logVO.setBuserid(backUser.getUserID());
			logVO.setMark(request.getParameter("mark"));
			logVO.setRole("2");
			logService.insertLog(logVO);
			
			request.setAttribute("approved", "单据已作废！");
			
		}
		
		this.resetToken(request);

		return mapping.findForward("success");
	}
	
	
	
	
	
	
	//获取各个职责人员自己要处理的列表
	public ActionForward returnToList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		if(userService.getDkze()==null){
			wForm.setDkze("0");
		}else{
			wForm.setDkze(userService.getDkze()+"");
		}
		
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
		int month = cal.get(Calendar.MONTH )+1;
		wForm.getUserVO().setYear_search(year+"");
		wForm.getUserVO().setMonth_search(month+"");
		
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		

		map.put("year", wForm.getUserVO().getYear_search());
		map.put("month", wForm.getUserVO().getMonth_search());
		
		
		int noPayCount =userService.getNotPayCount(map);
		request.setAttribute("noPayCount", noPayCount);
		
		if(!backUser.getRoleid().equals("7")&&!backUser.getRoleid().equals("8")&&!backUser.getRoleid().equals("9")&&!backUser.getRoleid().equals("10")){
			int historyCount=userService.getHistoryCount(map);		
			request.setAttribute("historyCount", historyCount);
			
		}
		
		if(backUser.getRoleid().equals("9")){
			request.setAttribute("yyCount", userService.getYYtxCount(map));
			request.setAttribute("bxCount", userService.getBXtxCount(map));
			request.setAttribute("xsCount", userService.getXStxCount(map));
		}
		
		

		if(backUser.getRoleid().equals("7")){
			request.setAttribute("fcCount", userService.getFcCount());
		}
		
		
		
		
		if(backUser.getRoleid().equals("2")){
			int dktxCount=userService.getdktxCount(map);
			request.setAttribute("dktxCount", dktxCount);
		}
		
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}
		
		//监管需要查询所有单据
		if(backUser.getRoleid().equals("9")){
			map.put("noWorkflow", "true");
			
		}
		
		//财务需要查询封存单据
		if(backUser.getRoleid().equals("7")){
			map.put("roleid", "7");
			
		}
		
		int dataCount = userService.getdataCount(map);
		request.setAttribute("dataCount", dataCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		request.setAttribute("total",dataCount );
		
		request.setAttribute("url","returnToList" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(dataCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getdatalist(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("waitList");
	}
	
	
	
	
	//获取行驶证提醒列表
	public ActionForward returnToXstx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		if(!backUser.getRoleid().equals("9")){
				response.sendRedirect("login.do?callMethod=forwardLogin");
				return null;
		}
		
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
		int month = cal.get(Calendar.MONTH )+1;
		wForm.getUserVO().setYear_search(year+"");
		wForm.getUserVO().setMonth_search(month+"");
		
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		

		map.put("year", wForm.getUserVO().getYear_search());
		map.put("month", wForm.getUserVO().getMonth_search());
		
		
		int noPayCount =userService.getNotPayCount(map);
		request.setAttribute("noPayCount", noPayCount);
		
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		map.put("noWorkflow", "true");
		int dataCount = userService.getdataCount(map);
		request.setAttribute("dataCount", dataCount);
		
		request.setAttribute("yyCount", userService.getYYtxCount(map));
		request.setAttribute("bxCount", userService.getBXtxCount(map));
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}
		
		
		int xsCount = userService.getXStxCount(map);
		request.setAttribute("xsCount", xsCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		
		request.setAttribute("total",xsCount );
		
		request.setAttribute("url","returnToXstx" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(xsCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getXStxList(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("xsList");
	}
	
	//获取行驶证提醒列表
	public ActionForward returnToFcList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		if(!backUser.getRoleid().equals("7")){
				response.sendRedirect("login.do?callMethod=forwardLogin");
				return null;
		}
		
		if(userService.getDkze()==null){
			wForm.setDkze("0");
		}else{
			wForm.setDkze(userService.getDkze()+"");
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		int dataCount = userService.getdataCount(map);
		request.setAttribute("dataCount", dataCount);
		
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}
		
		
		int fcCount = userService.getFcCount();
		request.setAttribute("fcCount", fcCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		
		request.setAttribute("total",fcCount );
		
		request.setAttribute("url","returnToFcList" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(fcCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getFcList(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("historyList");
	}
	
	//获取营运证提醒列表
	public ActionForward returnToYytx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		if(!backUser.getRoleid().equals("9")){
			response.sendRedirect("login.do?callMethod=forwardLogin");
			return null;
		}
		
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
		int month = cal.get(Calendar.MONTH )+1;
		wForm.getUserVO().setYear_search(year+"");
		wForm.getUserVO().setMonth_search(month+"");
		
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		

		map.put("year", wForm.getUserVO().getYear_search());
		map.put("month", wForm.getUserVO().getMonth_search());
		
		
		int noPayCount =userService.getNotPayCount(map);
		request.setAttribute("noPayCount", noPayCount);
		
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		map.put("noWorkflow", "true");
		int dataCount = userService.getdataCount(map);
		request.setAttribute("dataCount", dataCount);
		
		request.setAttribute("bxCount", userService.getBXtxCount(map));
		request.setAttribute("xsCount", userService.getXStxCount(map));
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}
		
		
		int yyCount = userService.getYYtxCount(map);
		request.setAttribute("yyCount", yyCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		
		request.setAttribute("total",yyCount );
		
		request.setAttribute("url","returnToYytx" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(yyCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getYYtxList(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("xsList");
	}
	
	//获取保险提醒列表
	public ActionForward returnToBxtx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		if(!backUser.getRoleid().equals("9")){
			response.sendRedirect("login.do?callMethod=forwardLogin");
			return null;
		}
		
		
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
		int month = cal.get(Calendar.MONTH )+1;
		wForm.getUserVO().setYear_search(year+"");
		wForm.getUserVO().setMonth_search(month+"");
		
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		

		map.put("year", wForm.getUserVO().getYear_search());
		map.put("month", wForm.getUserVO().getMonth_search());
		
		
		int noPayCount =userService.getNotPayCount(map);
		request.setAttribute("noPayCount", noPayCount);
		
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		map.put("noWorkflow", "true");
		int dataCount = userService.getdataCount(map);
		request.setAttribute("dataCount", dataCount);
		
		request.setAttribute("yyCount", userService.getYYtxCount(map));
		request.setAttribute("xsCount", userService.getXStxCount(map));
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}
		
		
		int bxCount = userService.getBXtxCount(map);
		request.setAttribute("bxCount", bxCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		
		request.setAttribute("total",bxCount );
		
		request.setAttribute("url","returnToBxtx" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(bxCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getBXtxList(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("xsList");
	}
	
	private void resetSkip(HttpServletRequest request,String offset,HashMap<String,Object> map){
		if(offset==null){
			map.put("skip", 0);
		}else{
			if(new Integer(offset)!=0){
				map.put("skip", new Integer(offset));
			}else{
				map.put("skip", 0);
			}			
		}
		
	}
	
	public ActionForward returnTobackList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		WriteReceiptForm wForm = (WriteReceiptForm) form;
		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		int historyCount=userService.getHistoryCount(map);
		request.setAttribute("historyCount", historyCount);
		
		if(wForm.getUserVO().getUser_sn_search()!=null && ! wForm.getUserVO().getUser_sn_search().trim().equals("")){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(wForm.getUserVO().getUser_name_search()!=null && ! wForm.getUserVO().getUser_name_search().trim().equals("")){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}
		
		
		//查询退回的标志
		map.put("returnData", true);
		
		int dataCount=userService.getHistoryCount(map);
		request.setAttribute("returnCount", dataCount);
		
		request.setAttribute("total",dataCount );
		resetSkip(request,request.getParameter("pager.offset"),map);
		request.setAttribute("url","returnTobackList" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		List<HashMap<String,Object>> dataList=null;
		if(dataCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getHistoryList(map);
		}
		request.setAttribute("dateReturnList", dataList);
		
		return mapping.findForward("backList");
	} 
	
	
	public ActionForward returnTohistoryList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		WriteReceiptForm wForm = (WriteReceiptForm) form;
		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		if(userService.getDkze()==null){
			wForm.setDkze("0");
		}else{
			wForm.setDkze(userService.getDkze()+"");
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		int dktxCount=userService.getdktxCount(map);
		request.setAttribute("dktxCount", dktxCount);
		
		if(wForm.getUserVO().getUser_sn_search()!=null && ! wForm.getUserVO().getUser_sn_search().trim().equals("")){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(wForm.getUserVO().getUser_name_search()!=null && ! wForm.getUserVO().getUser_name_search().trim().equals("")){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}	
		if(request.getParameter("returnData")!=null){
			map.put("returnData", true);
		}
		
		int dataCount = userService.getHistoryCount(map);
		request.setAttribute("historyCount", dataCount);
		
		
		
		request.setAttribute("total",dataCount );
		resetSkip(request,request.getParameter("pager.offset"),map);
		request.setAttribute("url","returnTohistoryList" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		List<HashMap<String,Object>> dataList=null;
		if(dataCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getHistoryList(map);
		}
		request.setAttribute("dateReturnList", dataList);
		
		if(backUser.getRoleid().equals("1")){
			map.put("returnData", "true");
			request.setAttribute("returnCount", userService.getHistoryCount(map));
		
		}else{
			request.setAttribute("dataCount", userService.getdataCount(map));
		}
			request.setAttribute("history", true);
		
		
		return mapping.findForward("historyList");
	} 
	
	
	
	
	//监管员提交还款计划
	
	public ActionForward payByMonth(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		BackUserVO  backUser=(BackUserVO)session.getAttribute("buser");
		if (backUser == null) {
			response.sendRedirect("login.do?callMethod=forwardLogin");
			return null;
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("usertableid",wForm.getUserVO().getId()+"");
		map.put("year", wForm.getHknf());
		map.put("month", wForm.getHkyf());
		
		int existPay  =userService.existPay(map);
		
		if(existPay!=0){
			if(backUser.getRoleid().equals("9")||backUser.getRoleid().equals("7")){
				request.setAttribute("payList", userService.getPay(wForm.getUserVO().getId()+""));
			}else{
				request.setAttribute("payList", null);
			}
			
			request.setAttribute("existPay", "1");
			return mapping.findForward("input");
			
		}else{
			userService.insertPay(map);
			if(backUser.getRoleid().equals("9")||backUser.getRoleid().equals("7")){
				request.setAttribute("payList", userService.getPay(wForm.getUserVO().getId()+""));
			}else{
				request.setAttribute("payList", null);
			}
		}
		
		
		return mapping.findForward("input");
	} 
	public ActionForward toUpdatedktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("dktx");
	}
	
	public ActionForward toQueryNoPay(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;
		
		BackUserVO  backUser=(BackUserVO)session.getAttribute("buser");
		if (backUser == null) {
			response.sendRedirect("login.do?callMethod=forwardLogin");
			return null;
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		
		
		if(wForm.getUserVO().getYear_search()==null||"".equals(wForm.getUserVO().getYear_search())){
			Calendar cal = Calendar.getInstance();
			int year = cal.get(Calendar.YEAR);
			int month = cal.get(Calendar.MONTH )+1;
			wForm.getUserVO().setYear_search(year+"");
			wForm.getUserVO().setMonth_search(month+"");
			
		}
		
		
		//监管需要查询所有单据
		if(backUser.getRoleid().equals("9")){
			map.put("noWorkflow", "true");
			
		}
	
		
		int dataCount = userService.getdataCount(map);
		request.setAttribute("dataCount", dataCount);
		
		request.setAttribute("yyCount", userService.getYYtxCount(map));
		request.setAttribute("bxCount", userService.getBXtxCount(map));
		request.setAttribute("xsCount", userService.getXStxCount(map));
		
		map.put("year", wForm.getUserVO().getYear_search());
		map.put("month", wForm.getUserVO().getMonth_search());
		
		
		int noPayCount =userService.getNotPayCount(map);
		request.setAttribute("noPayCount", noPayCount);
		request.setAttribute("total",noPayCount );
		resetSkip(request,request.getParameter("pager.offset"),map);
		request.setAttribute("url","toQueryNoPay" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		List<HashMap<String,Object>> dataList;
		if(noPayCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getNotPay(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("notPayList");
	}
	
	public ActionForward toUpdateBzj(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("bzj");
	}
	
	
	
	public ActionForward updatedktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("dk2", request.getParameter("dktx"));
		map.put("dked", request.getParameter("dked"));
		map.put("usertableid", request.getParameter("tableID"));
		userService.updateDktx(map);
		request.setAttribute("dktxSuccess", "true");
		return mapping.findForward("dktx");
	}
	
	public ActionForward updateJgtx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("tx", request.getParameter("tx"));
		map.put("usertableid", request.getParameter("tableID"));
		userService.updateJgtx(map);
		request.setAttribute("jgtxSuccess", "true");
		return mapping.findForward("txC");
	}
	
	
	
	public ActionForward toCompletedktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("dktxC");
	}
	
	public ActionForward toCompletetx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("txC");
	}
	
	
	public ActionForward completedktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("usertableid", request.getParameter("tableID"));
		userService.completeDktx(map);
		request.setAttribute("dktxSuccess", "true");
		return mapping.findForward("dktxC");
	}
	
	public ActionForward toUpdateGPStx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("gpstx");
	}
	
	public ActionForward updategpstx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("gps2", request.getParameter("gpstx"));
		map.put("usertableid", request.getParameter("tableID"));
		userService.updateGPStx(map);
		request.setAttribute("gpstxSuccess", "true");
		return mapping.findForward("gpstx");
	}
	public ActionForward updateBzj(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("bzj_true", request.getParameter("bzj"));
		map.put("usertableid", request.getParameter("tableID"));
		userService.updateBzj(map);
		request.setAttribute("bzjSuccess", "true");
		return mapping.findForward("bzj");
	}
	
	
	
	
	public ActionForward toCompleteGPStx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("gpstxC");
	}
	
	public ActionForward toCompleteGptx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("gptxC");
	}
	
	public ActionForward completegpstx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("usertableid", request.getParameter("tableID"));
		if(backUser.getRoleid().equals("10")){
			userService.completeGPS4tx(map);
			request.setAttribute("gps4", 1);
		}else{
			userService.completeGPStx(map);
		}
		
		
		request.setAttribute("gpstxSuccess", "true");
		return mapping.findForward("gpstxC");
	}
	
	public ActionForward completegptx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("usertableid", request.getParameter("tableID"));
		
			userService.completeGptx(map);
		
		
		request.setAttribute("gptxSuccess", "true");
		return mapping.findForward("gptx");
	}
	
	public ActionForward completeGp2tx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("usertableid", request.getParameter("tableID"));
		
			userService.completeGp2tx(map);
		
		
		request.setAttribute("gptxSuccess", "true");
		return mapping.findForward("gptxC");
	}
	
	
	
	
	
	
	public ActionForward toUpdateFktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward("fktx");
	}
	
	public ActionForward updateFktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("fk2", request.getParameter("fktx"));
		map.put("usertableid", request.getParameter("tableID"));
		userService.updateFktx(map);
		request.setAttribute("fktxSuccess", "true");
		return mapping.findForward("fktx");
	}
	
	public ActionForward toCompleteFktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("fktxC");
	}
	
	public ActionForward toUpdateGptx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("gptx");
	}
	
	public ActionForward toUpdateGPS4tx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("GPS4tx");
	}
	
	public ActionForward completeFktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("usertableid", request.getParameter("tableID"));
		userService.completeFktx(map);
		request.setAttribute("fktxSuccess", "true");
		return mapping.findForward("fktxC");
	}
	
	
	public ActionForward returnToDktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		int historyCount=userService.getHistoryCount(map);		
		request.setAttribute("historyCount", historyCount);
		
		
		
		int dataCount=userService.getdataCount(map);
		request.setAttribute("dataCount", dataCount);
		
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}

		
		int dktxCount = userService.getdktxCount(map);
		request.setAttribute("dktxCount", dktxCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		
		request.setAttribute("total",dktxCount );
		
		
		request.setAttribute("url","returnToDktx" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(dktxCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getdktxList(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("txList");
	}
	
	public ActionForward returnToGPStx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}

		
		int gpstxCount = userService.getGPStxCount(map);
		request.setAttribute("dataCount", gpstxCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		
		request.setAttribute("total",gpstxCount );
		
		
		request.setAttribute("url","returnToGPStx" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(gpstxCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getGPStxList(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("txList");
	}
	
	public ActionForward returnToFktx(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		WriteReceiptForm wForm = (WriteReceiptForm) form;

		if (backUser == null) {
			return mapping.findForward("fail");
		}
		
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("userid", backUser.getUserID());
		map.put("roleid", backUser.getRoleid());
		
		
		//封装搜索条件
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_sn_search())){
			map.put("usersn", wForm.getUserVO().getUser_sn_search());
		}
		if(!StringUtils.isEmpty(wForm.getUserVO().getUser_name_search())){
			map.put("username", wForm.getUserVO().getUser_name_search());
		}

		
		int fktxCount = userService.getFktxCount(map);
		request.setAttribute("dataCount", fktxCount);
		
		resetSkip(request,request.getParameter("pager.offset"),map);
		
		request.setAttribute("total",fktxCount );
		
		
		request.setAttribute("url","returnToGPStx" );
		request.setAttribute("maxCount", wForm.getMaxCount());
		map.put("limit", wForm.getMaxCount());
		
		
		List<HashMap<String,Object>> dataList=null;
		if(fktxCount==0){
			 dataList=new ArrayList<HashMap<String,Object>>();
		}else{
			dataList = userService.getFktxList(map);
		}
		
		request.setAttribute("dateReturnList", dataList);
		return mapping.findForward("txList");
	}
	
	
	
}
